import Vue from 'vue'
function timeFormatter(cell, needHour) {
  const date = new Date(cell)
  const year = date.getFullYear()
  let month = date.getMonth() + 1
  month = month >= 10 ? month : '0' + month
  let d1 = date.getDate()
  d1 = d1 >= 10 ? d1 : '0' + d1
  let time_str = year + '-' + month + '-' + d1
  if (needHour) {
    let h = date.getHours()
    h = h >= 10 ? h : '0' + h
    let m = date.getMinutes()
    m = m >= 10 ? m : '0' + m
    time_str += (' ' + h + ':' + m)
  }
  return cell ? time_str : '--'
}
Vue.prototype.$format = timeFormatter
